<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url() . '/style/admin/css/public.css' ?>">
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
	<title>节点管理</title>
	<style type="text/css">
		#wrap {
			width: 94%;
			height: auto;
			overflow: hidden;
			margin: 0px 10px;
			padding: 0px 10px;
		}
		#wrap dl{
			margin: 10px 0px;
			border: 1px solid #dcdcdc;
			height: auto;
			overflow: hidden;
		}
		#wrap dl dt{
			display: block;
			height: 36px;
			line-height: 36px;
			background: #e6e6fa;
			text-indent: 10px;
		}
		#wrap dl dt strong{
			font-size: 16px;
			color: #61aefa;
		}

		#wrap dl dd {
			padding: 10px;
			float: left;
		}
	</style>
	<script type="text/javascript">
		$(function(){
			$('input[level=1]').click(function(){
				var inputs = $(this).parents('dl').find('input');
				console.log(inputs.val());
				$(this).attr('checked') ? inputs.attr('checked','checked') : inputs.removeAttr('checked');
			});
			$('input[level=2]').click(function(){
				var input = $(this).parent().parents('dl').find('dt input');
				var dd_inputs = $(this).parent().parents('dl').find('dd input:checked');
				if (dd_inputs.length >= 1) {
					input.attr('checked','checked');
				} else {
					input.removeAttr('checked');
				}

			})

		})
	</script>
</head>
<body>
	
	<table class="table">
		<tr>
			<td class="th" colspan="10">权限配置</td>
		</tr>
		<tr>
			<td>
			<form action="" method="post">
				<div id="wrap" level="1">
					<?php foreach ($nodes as $key => $value): ?>
					<dl>
						<dt>
							<input type="checkbox" name="rules[]" value="<?php echo $value['id'] ?>" <?php echo $value['access']?"checked='checked'":'' ?> level="1"/><strong>&nbsp;<?php echo $value['title']; ?></strong>
						</dt>
						<?php foreach ($value['child'] as $k => $v): ?>
							<dd>
								<input type="checkbox" name="rules[]" value="<?php echo $v['id'] ?>" <?php echo $v['access']?"checked=checked":'' ?> level="2"/><span>&nbsp;<?php echo $v['title'] ?></span>
							</dd>
						<?php endforeach ?>
					</dl>
					<?php endforeach ?>
					<input type="submit" name="post" value="提交" class="input_button"/>
				</div>
			</form>
			</td>
		</tr>
	</table>
</body>
</html>